<template>
    <yh-dialog drag :title="dialogVO.title" :visible.sync="dialogVO.visible" v-if="dialogVO.visible" :before-close="closeDialog">
        <el-form ref="form" :model="checkRuleDetailVO" v-loading="loading">
            <div class="dialog-container">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="规则名称:" :label-width="formLabelWidth">
                            <el-input placeholder="请输入规则名称" v-model="checkRuleDetailVO.checkRule.ruleName" size="mini"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="规则来源:" :label-width="formLabelWidth">
                            <el-select size="mini" v-model="checkRuleDetailVO.checkRule.ruleSource">
                                <el-option value="静态">静态</el-option>
                                <el-option value="实时">实时</el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="规则等级:" :label-width="formLabelWidth">
                            <el-select size="mini" v-model="checkRuleDetailVO.checkRule.ruleGrade">
                                <el-option v-for="(value, key) in ruleGrades" :key="key" :value="key" :label="key + ' ' + value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="关联关系:" :label-width="formLabelWidth">
                            <el-select v-model="checkRuleDetailVO.checkRule.relationType" size="mini">
                                <el-option v-for="(value, key) in checkRuleRelations" :key="key" :label="key + ' ' + value" :value="key"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="因子序号:" :label-width="formLabelWidth" v-if="checkRuleDetailVO.checkRule.relationType === '1'">
                            <el-select size="mini" v-model="checkRuleDetailVO.checkRule.enCalFacCode">
                                <el-option
                                    v-for="(item, key) in calculateFactors"
                                    :key="key"
                                    :label="key + ' ' + item.entryCalculateFactorName"
                                    :value="key"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="范围序号:" :label-width="formLabelWidth" v-if="checkRuleDetailVO.checkRule.relationType === '2'">
                            <el-select size="mini" v-model="checkRuleDetailVO.checkRule.boundCode">
                                <el-option v-for="(item, key) in boundCfg" :key="key" :label="key + ' ' + item.boundName" :value="key"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="检查类型:" :label-width="formLabelWidth">
                            <el-select size="mini" v-model="checkRuleDetailVO.checkRule.ruleType">
                                <el-option v-if="checkRuleDetailVO.checkRule.relationType != '3'" label="" value=""></el-option>
                                <el-option v-for="(item, key) in computedRuleTypes" :key="key" :label="item" :value="key"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-form-item label="规则说明:" :label-width="formLabelWidth">
                    <el-input type="textarea" placeholder="请输入规则说明" v-model="checkRuleDetailVO.checkRule.ruleDescroption"></el-input>
                </el-form-item>
                <el-form-item label="是否开启:" :label-width="formLabelWidth">
                    <el-switch v-model="checkRuleDetailVO.checkRule.isOpen" active-value="1" inactive-value="0"></el-switch>
                </el-form-item>
                <el-divider v-if="checkRuleDetailVO.checkRule.ruleType !== ''"></el-divider>
                <div v-if="checkRuleDetailVO.checkRule.ruleType === '1'" key="checkRule">
                    <p>表数据量配置</p>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="检查表名:" :label-width="formLabelWidth" key="1">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableDatasize.checkTable">
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in allTable"
                                        :key="item.tableName"
                                        :label="item.tableName + ' ' + item.tableComments"
                                        :value="item.tableName"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="比较方向:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableDatasize.compareType">
                                    <el-option v-for="(value, key) in compareTypes" :key="key" :label="value" :value="key"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="阈值:" :label-width="formLabelWidth">
                                <el-input-number
                                    controls-position="right"
                                    size="mini"
                                    v-model="checkRuleDetailVO.checkTableDatasize.expectCount"
                                ></el-input-number>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div v-if="['2', '3'].includes(checkRuleDetailVO.checkRule.ruleType)" key="checkTableRelate">
                    <p>关联关系配置</p>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="检查表名:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableRelate.checkTable" @change="relateCheckTableChange">
                                    <el-option label="" value=""></el-option>
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in allTable"
                                        :key="item.tableName"
                                        :label="item.tableName + ' ' + item.tableComments"
                                        :value="item.tableName"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="目标表名:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableRelate.relateTable" @change="relateTableChange">
                                    <el-option label="" value=""></el-option>
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in allTable"
                                        :key="item.tableName"
                                        :label="item.tableName + ' ' + item.tableComments"
                                        :value="item.tableName"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="字段:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableRelate.checkField">
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in relateCheckField"
                                        :key="item"
                                        :label="item"
                                        :value="item"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="字段:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableRelate.relateField"
                                    ><el-option
                                        style="max-width: 350px"
                                        v-for="item in relateTargetField"
                                        :key="item"
                                        :label="item"
                                        :value="item"
                                    ></el-option
                                ></el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div v-if="['4', '5', '6', '7'].includes(checkRuleDetailVO.checkRule.ruleType)" key="checkTableField">
                    <p>字段配置</p>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="检查表名:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableField.checkTable" @change="fieldCheckTableChange">
                                    <el-option label="" value=""></el-option>
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in allTable"
                                        :key="item.tableName"
                                        :label="item.tableName + ' ' + item.tableComments"
                                        :value="item.tableName"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="检查字段:" :label-width="formLabelWidth">
                                <el-select style="max-width: 350px" size="mini" v-model="checkRuleDetailVO.checkTableField.checkField">
                                    <el-option v-for="item in fieldColumn" :key="item" :label="item" :value="item"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" v-if="checkRuleDetailVO.checkRule.ruleType === '4'">
                            <el-form-item label="字典:" :label-width="formLabelWidth">
                                <el-select style="max-width: 350px" v-model="checkRuleDetailVO.checkTableField.dictionaryCode">
                                    <el-option
                                        v-for="item in allDicInfo"
                                        :key="item.dicCode"
                                        :label="item.dicCode + ' ' + item.dicValue"
                                        :value="item.dicCode"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
                <div v-if="checkRuleDetailVO.checkRule.ruleType === '8'" key="checkTableCustom">
                    <p>自定义sql配置</p>
                    <el-row>
                        <el-col>
                            <el-form-item label="检查表名:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableCustom.checkTable" @change="relateCheckTableChange">
                                    <el-option
                                        style="max-width: 350px"
                                        v-for="item in allTable"
                                        :key="item.tableName"
                                        :label="item.tableName + ' ' + item.tableComments"
                                        :value="item.tableName"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="触发等级:" :label-width="formLabelWidth">
                                <el-select size="mini" v-model="checkRuleDetailVO.checkTableCustom.checkLevel">
                                    <el-option v-for="(value, key) in checkLevels" :key="key" :label="key + ' ' + value" :value="key"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item label="SQL语句:" :label-width="formLabelWidth"
                        ><el-input
                            type="textarea"
                            placeholder="请输入正确的sql语句,查询字段必须只有主键"
                            v-model="checkRuleDetailVO.checkTableCustom.checkSql"
                        ></el-input
                    ></el-form-item>
                </div>
                <div v-if="checkRuleDetailVO.checkRule.ruleType === '9'">
                    <el-form-item label="存储过程名称:" label-width="130px">
                        <el-select
                            size="mini"
                            v-model="checkRuleDetailVO.checkRule.programName"
                            @change="fieldCheckTableChange"
                            filterable
                            style="width: 100%"
                        >
                            <el-option
                                style="max-width: 350px"
                                v-for="(item, index) in procedureData"
                                :key="index"
                                :label="item"
                                :value="item"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </div>
            </div>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="closeDialog">取 消</el-button>
            <el-button type="primary" @click="submit" v-if="dialogVO.action !== 0">确 定</el-button>
        </div>
    </yh-dialog>
</template>

<script lang="ts">
import { DialogVO } from '@yhfin/biz';
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import DictionConstUtil from '@/utils/diction-const-util';
import { checkRuleDetailVO, CheckRuleVO, CheckTableCustomVO, CheckTableDatasizeVO, CheckTableFieldVO, CheckTableRelateVO } from './detail';
import CheckSettingConstUtil from '../dict/check';

@Component({
    name: 'CheckSettingDetail',
})
export default class CheckSettingDetail extends Vue {
    // 操作勾稽规则弹窗对象
    @Prop()
    dialogVO: DialogVO;
    @Prop()
    formData: any;
    @Prop()
    ruleId: string;
    private formLabelWidth = '100px';
    private loading = false;

    private ruleType = {
        '1': '表数据量配置',
        '2': '关联关系一对一配置',
        '3': '关联关系一对多配置',
        '4': '字段字典配置',
        '5': '字段日期配置',
        '6': '字段时间配置',
        '7': '字段非NULL配置',
        '8': '自定义sql配置',
        '9': '存储过程',
    };

    // 检查类型
    // private ruleTypes = CheckSettingConstUtil.RuleType();
    // 计算因子
    private calculateFactors = {};
    // 证券范围
    private boundCfg = {};
    // 所有表名
    private allTable: any[] = [];
    // 所以字典信息
    private allDicInfo = [];
    // 比较方向
    private compareTypes = CheckSettingConstUtil.CompareType;
    // 勾稽等级
    private ruleGrades = CheckSettingConstUtil.RuleGrade;
    // 触发等级
    private checkLevels = CheckSettingConstUtil.CheckLevel;
    // 关联关系
    private checkRuleRelations = CheckSettingConstUtil.CheckRuleRelation;
    // 勾稽规则基本信息表单对象
    private checkRuleVO: CheckRuleVO = {
        ruleId: '', // 规则序号
        ruleName: '', // 规则名称
        ruleDescroption: '', // 规则说明
        ruleSource: '', // 规则来源
        ruleGrade: '', // 勾稽等级
        isProduct: '', // 是否内置：0 -不是 1- 是（内置的规则不允许编辑）
        ruleType: '',
        programName: '', // 程序名称（java程序 写类的全路径；存储过程填存储过程名称）
        boundCode: '', // 关联范围
        enCalFacCode: '', // 关联因子
        BoundOrEnCalFacName: '', // 范围或因子名称
        isOpen: '1', // 是否开启(关联因子/范围开，这里也开启才是真正的开启）
        createDate: null, // 创建日期
        createTime: null, // 创建时间
        createUser: '', // 创建人
    };
    // 表数据量大小服务处理对象
    private checkTableDatasizeVO: CheckTableDatasizeVO = {
        keyCode: '',
        ruleId: '',
        checkTable: '', // 检验表
        compareType: '', // 比较类型:字典大于小于等于
        expectCount: 0, // 阈值
        checkSql: '', // SQL解析结果
    };
    // 表关联关系服务处理对象
    private checkTableRelateVO: CheckTableRelateVO = {
        keyCode: '',
        ruleId: '',
        checkTable: '', // 检查表
        checkField: '', // 检查表字段
        relateTable: '', // 目标表
        relateField: '', // 目标字段
        relateType: '', // 类型：1-一对一，2-主从关系
        checkSql: '', // SQL解析结果
    };
    // 表关联关系服务处理 目标表表字段
    private relateTargetField = [];
    // 表关联关系服务处理 检查表表字段
    private relateCheckField = [];
    // 表自定义字段服务处理对象
    private checkTableFieldVO: CheckTableFieldVO = {
        keyCode: '',
        ruleId: '',
        checkTable: '',
        checkField: '',
        checkType: '', // 检查类型：1-字典，2-日期，3-时间
        dictionaryCode: '', // 字典编号
        checkSql: '', // SQL解析结果
    };
    // 表自定义字段服务处理 检查表表字段
    private fieldColumn = [];
    // 表自定义sql字段处理对象
    private checkTableCustomVO: CheckTableCustomVO = {
        keyCode: '',
        ruleId: '',
        checkTable: '', // 检验表
        checkField: '',
        checkSql: '', // SQL解析结果
        checkLevel: '', // 触发级别：1、有值存在 2、无值存在
    };
    // 勾稽规则详细信息对象
    private checkRuleDetailVO = {
        checkRule: {
            boundCode: '',
            boundName: '',
            createDate: 0,
            createTime: 0,
            createUser: '',
            enCalFacCode: '',
            enCalFacName: '',
            isOpen: '1',
            isProduct: '',
            programName: '',
            ruleDescroption: '',
            ruleGrade: '',
            ruleId: '',
            ruleName: '',
            ruleSource: '',
            ruleType: '',
            relationType: '1',
        },
        checkTableCustom: {
            checkField: '',
            checkLevel: '',
            checkSql: '',
            checkTable: '',
            keyCode: '',
            ruleId: '',
        },
        checkTableDatasize: {
            checkSql: '',
            checkTable: '',
            compareType: '',
            expectCount: 0,
            keyCode: '',
            ruleId: '',
        },
        checkTableField: {
            checkField: '',
            checkSql: '',
            checkTable: '',
            checkType: '',
            dictionaryCode: '',
            keyCode: '',
            ruleId: '',
        },
        checkTableRelate: {
            checkField: '',
            checkSql: '',
            checkTable: '',
            keyCode: '',
            relateField: '',
            relateTable: '',
            relateType: '',
            ruleId: '',
        },
    };
    // 勾稽规则关联关系
    private checkRuleRelation: string = '1';
    private procedureData: any[] = []; // 存储过程下拉数据

    // 初始化
    async mounted() {
        // 获取计算因子
        // this.calculateFactors = DictionConstUtil.ListToPojo2('entryCalculateFactorCode', await DictionConstUtil.FNCalculateFactor());
        // // 获取证券范围
        // this.boundCfg = DictionConstUtil.ListToPojo2('boundCode', await DictionConstUtil.FNBoundCfg());
        // // 获取所有表名
        // this.allTable = await CheckSettingConstUtil.Table();
        // // 获取所有字典信息
        // this.allDicInfo = await CheckSettingConstUtil.AllDicInfo();
    }

    @Watch('ruleId', { immediate: true, deep: true })
    async initData() {
        this.resetForm();

        if (this.dialogVO.action === 0 || this.dialogVO.action === 2) {
            this.loading = true;
            this.$axios.get('/checkRule/getDetail/' + this.ruleId).then((res: any) => {
                for (let key in this.checkRuleDetailVO.checkRule) {
                    this.checkRuleDetailVO.checkRule[key] = res.checkRule[key];
                }
                if (this.checkRuleDetailVO.checkRule.ruleType === '1') {
                    this.checkRuleDetailVO.checkTableDatasize = res.checkTableDatasize;
                } else if (['2', '3'].includes(this.checkRuleDetailVO.checkRule.ruleType)) {
                    this.checkRuleDetailVO.checkTableRelate = res.checkTableRelate;
                } else if (['4', '5', '6', '7'].includes(this.checkRuleDetailVO.checkRule.ruleType)) {
                    this.checkRuleDetailVO.checkTableField = res.checkTableField;
                } else if (this.checkRuleDetailVO.checkRule.ruleType === '8') {
                    this.checkRuleDetailVO.checkTableCustom = res.checkTableCustom;
                }
                if (res.checkRule.enCalFacCode || res.checkRule.boundCode) {
                    if (res.checkRule.enCalFacCode !== undefined) {
                        this.checkRuleDetailVO.checkRule.relationType = '1';
                    } else {
                        this.checkRuleDetailVO.checkRule.relationType = '2';
                    }
                } else {
                    this.checkRuleDetailVO.checkRule.relationType = '3';
                }

                this.loading = false;
            });
        }
        // 获取计算因子
        this.calculateFactors = DictionConstUtil.ListToPojo2('entryCalculateFactorCode', await DictionConstUtil.FNCalculateFactor());
        // 获取证券范围
        this.boundCfg = DictionConstUtil.ListToPojo2('boundCode', await DictionConstUtil.FNBoundCfg());
        // 获取所有表名
        this.allTable = await CheckSettingConstUtil.Table();
        // 获取所有字典信息
        this.allDicInfo = await CheckSettingConstUtil.AllDicInfo();
        this.queryProcedure();
    }

    get computedRuleTypes() {
        if (this.checkRuleDetailVO.checkRule.relationType == '3') {
            this.checkRuleDetailVO.checkRule.boundCode = '';
            this.checkRuleDetailVO.checkRule.enCalFacCode = '';
            this.checkRuleDetailVO.checkRule.ruleType = '9';
            return { '9': '存储过程' };
        } else {
            return this.ruleType;
        }
    }

    // 表关联关系服务处理 检查表名改变处理
    private relateCheckTableChange(tableName) {
        this.$axios.get('common/getField/' + tableName).then((res: any) => {
            this.relateCheckField = res;
        });
    }
    // 表关联关系服务处理 目标表名改变处理
    private relateTableChange(tableName) {
        this.$axios.get('common/getField/' + tableName).then((res: any) => {
            this.relateTargetField = res;
        });
    }
    // 表自定义字段服务处理 检查表名改变处理
    private fieldCheckTableChange(tableName) {
        this.$axios.get('common/getField/' + tableName).then((res: any) => {
            this.fieldColumn = res;
        });
    }
    // 新增/修改后刷新数据
    private refresh() {
        this.$emit('refresh');
    }

    // 处理数据提交
    private submit() {
        let validRes = this.verifyRuleDetailParam(this.checkRuleDetailVO);
        if (validRes === 'Success') {
            this.$axios.post('/checkRule/addOrUpd', this.checkRuleDetailVO).then((res: any) => {
                console.log(res);
                this.yh_message_success('操作成功');
                this.refresh();
                this.resetForm();
                this.dialogVO.visible = false;
            });
        } else {
            this.yh_message_error(validRes);
            return;
        }
    }

    // 查询存储过程
    private queryProcedure() {
        this.$axios
            .get('/common/list/procedure')
            .then((res: any) => {
                this.procedureData = res;
            })
            .catch(() => {
                this.procedureData = [];
            });
    }

    // 关闭
    closeDialog() {
        this.resetForm();
        this.dialogVO.visible = false;
    }

    /**
     * 校验所填参数是否正确
     */
    verifyRuleDetailParam(ruleDetail) {
        if (ruleDetail.checkRule.ruleName === '') {
            return '规则名称不能为空';
        }
        if (ruleDetail.checkRule.ruleName.length > 200) {
            return '规则名称不能超过200字符';
        }
        if (ruleDetail.checkRule.ruleDescroption?.length > 1000) {
            return '规则说明不能超过1000字符';
        }
        if (this.checkRuleVO.ruleType === '1') {
            let checkTableDatasize = ruleDetail.checkTableDatasize;
            if (checkTableDatasize.checkTable === '') {
                return '检查表名不能为空';
            }
            if (checkTableDatasize.compareType === '') {
                return '比较方向不能为空';
            }
        } else if (['2', '3'].includes(this.checkRuleVO.ruleType)) {
            let checkTableRelate = ruleDetail.checkTableRelate;
            if (checkTableRelate.checkTable === '') {
                return '检查表名不能为空';
            }
            if (checkTableRelate.checkField === '') {
                return '检查字段不能为空';
            }
            if (checkTableRelate.relateTable === '') {
                return '目标表名不能为空';
            }
            if (checkTableRelate.relateField === '') {
                return '目标字段不能为空';
            }
        } else if (['4', '5', '6', '7'].includes(this.checkRuleVO.ruleType)) {
            let checkTableField = ruleDetail.checkTableField;
            if (checkTableField.checkTable === '') {
                return '检查表名不能为空';
            }
            if (checkTableField.checkField === '') {
                return '检查字段不能为空';
            }
            if (this.checkRuleVO.ruleType === '4' && checkTableField.dictionaryCode === '') {
                return '字典不能为空';
            }
        } else if (this.checkRuleVO.ruleType === '8') {
            let checkTableCustom = ruleDetail.checkTableCustom;
            if (checkTableCustom.checkTable === '') {
                return '检查表名不能为空';
            }
            if (checkTableCustom.checkLevel === '') {
                return '触发等级不能为空';
            }
            if (checkTableCustom.checkSql === '') {
                return 'SQL语句不能为空';
            }
        }
        return 'Success';
    }

    // 重置
    resetForm() {
        // 不建议走公司这套dialog 这套封装后好像不走生命周期了
        // 计算因子
        this.calculateFactors = {};
        // 证券范围
        this.boundCfg = {};
        // 所有表名
        this.allTable = [];
        // 所以字典信息
        this.allDicInfo = [];
        // 比较方向
        this.compareTypes = CheckSettingConstUtil.CompareType;
        // 勾稽等级
        this.ruleGrades = CheckSettingConstUtil.RuleGrade;
        // 触发等级
        this.checkLevels = CheckSettingConstUtil.CheckLevel;
        // 关联关系
        this.checkRuleRelations = CheckSettingConstUtil.CheckRuleRelation;
        // 勾稽规则基本信息表单对象
        this.checkRuleVO = {
            ruleId: '', // 规则序号
            ruleName: '', // 规则名称
            ruleDescroption: '', // 规则说明
            ruleSource: '', // 规则来源
            ruleGrade: '', // 勾稽等级
            isProduct: '', // 是否内置：0 -不是 1- 是（内置的规则不允许编辑）
            ruleType: '',
            programName: '', // 程序名称（java程序 写类的全路径；存储过程填存储过程名称）
            boundCode: '', // 关联范围
            enCalFacCode: '', // 关联因子
            BoundOrEnCalFacName: '', // 范围或因子名称
            isOpen: '1', // 是否开启(关联因子/范围开，这里也开启才是真正的开启）
            createDate: null, // 创建日期
            createTime: null, // 创建时间
            createUser: '', // 创建人
        };
        // 表数据量大小服务处理对象
        this.checkTableDatasizeVO = {
            keyCode: '',
            ruleId: '',
            checkTable: '', // 检验表
            compareType: '', // 比较类型:字典大于小于等于
            expectCount: 0, // 阈值
            checkSql: '', // SQL解析结果
        };
        // 表关联关系服务处理对象
        this.checkTableRelateVO = {
            keyCode: '',
            ruleId: '',
            checkTable: '', // 检查表
            checkField: '', // 检查表字段
            relateTable: '', // 目标表
            relateField: '', // 目标字段
            relateType: '', // 类型：1-一对一，2-主从关系
            checkSql: '', // SQL解析结果
        };
        // 表关联关系服务处理 目标表表字段
        this.relateTargetField = [];
        // 表关联关系服务处理 检查表表字段
        this.relateCheckField = [];
        // 表自定义字段服务处理对象
        this.checkTableFieldVO = {
            keyCode: '',
            ruleId: '',
            checkTable: '',
            checkField: '',
            checkType: '', // 检查类型：1-字典，2-日期，3-时间
            dictionaryCode: '', // 字典编号
            checkSql: '', // SQL解析结果
        };
        // 表自定义字段服务处理 检查表表字段
        this.fieldColumn = [];
        // 表自定义sql字段处理对象
        this.checkTableCustomVO = {
            keyCode: '',
            ruleId: '',
            checkTable: '', // 检验表
            checkField: '',
            checkSql: '', // SQL解析结果
            checkLevel: '', // 触发级别：1、有值存在 2、无值存在
        };
        // 勾稽规则详细信息对象
        this.checkRuleDetailVO = {
            checkRule: {
                boundCode: '',
                boundName: '',
                createDate: 0,
                createTime: 0,
                createUser: '',
                enCalFacCode: '',
                enCalFacName: '',
                isOpen: '1',
                isProduct: '',
                programName: '',
                ruleDescroption: '',
                ruleGrade: '',
                ruleId: '',
                ruleName: '',
                ruleSource: '',
                ruleType: '',
                relationType: '1',
            },
            checkTableCustom: {
                checkField: '',
                checkLevel: '',
                checkSql: '',
                checkTable: '',
                keyCode: '',
                ruleId: '',
            },
            checkTableDatasize: {
                checkSql: '',
                checkTable: '',
                compareType: '',
                expectCount: 0,
                keyCode: '',
                ruleId: '',
            },
            checkTableField: {
                checkField: '',
                checkSql: '',
                checkTable: '',
                checkType: '',
                dictionaryCode: '',
                keyCode: '',
                ruleId: '',
            },
            checkTableRelate: {
                checkField: '',
                checkSql: '',
                checkTable: '',
                keyCode: '',
                relateField: '',
                relateTable: '',
                relateType: '',
                ruleId: '',
            },
        };
        // 勾稽规则关联关系
        // this.checkRuleRelation = '1';
    }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog {
    margin-top: 5vh !important;
    margin-bottom: 40px;
    min-width: 920px;
    .el-dialog__body {
        padding: 10px;
        min-height: 67vh;
        max-height: 70vh;
    }
}
.dialog-container {
    width: 100%;
    height: 100%;
    border: 1px solid #c9c9c9;
    padding: 5px;
    /deep/.el-textarea__inner:focus {
        border-color: #409eff;
    }
}
</style>
